<%@ taglib prefix="page" uri="http://com.qipay/pagelib" %>
<%@ page language="java" import="com.qipay.admin.card.vo.CardBindVo" contentType="text/html;charset=utf-8" %>
<%@ page import="com.qipay.admin.tags.PageModel" %>
<%@ page import="org.apache.commons.collections.CollectionUtils" %>
<%@ page import="org.apache.commons.lang3.StringUtils" %>
<%@ page import="java.util.List" %>
<!doctype html>
<html>
<head>
    <jsp:include page="head.jsp"></jsp:include>
    <title>已绑定银行卡列表</title>
    <link rel="stylesheet" href="<%= request.getAttribute("StaticHost") %>/css/dataTables.bootstrap.min.css">
</head>
</head>
<body class="devpreview hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <jsp:include page="nav.jsp"></jsp:include>
    <jsp:include page="left.jsp"></jsp:include>
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-xs-12">
                    <div class="box border" >

                        <!-- /.box-header -->
                        <div class="box-body">
                            <table id="pLst" class="table table-bped table-hover">
                                <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>银行</th>
                                    <th>支行</th>
                                    <th>卡号</th>
                                    <th>姓名</th>
                                    <th>手机</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <%
                                    List<CardBindVo> list = (List<CardBindVo>) request.getAttribute("lst");
                                    PageModel pager = (PageModel) request.getAttribute("page");
                                    String url = pageContext.getRequest().getServletContext().getContextPath() + "/card/bind" + (StringUtils.isNotBlank(pager.getUrl()) ? pager.getUrl() : "");
                                    if (CollectionUtils.isNotEmpty(list)) {
                                        for (CardBindVo p : list) {
                                %>
                                <tr id="p_<%=p.getId()%>">
                                    <td>
                                        <%= p.getId()%>
                                    </td>
                                    <td>
                                        <%= p.getBank()%>
                                    </td>
                                    <td>
                                        <%= p.getSubBank()%>
                                    </td>
                                    <td>
                                        <%= p.getCard()%>
                                    </td>
                                    <td>
                                        <%= p.getName()%>
                                    </td>
                                    <td>
                                        <%= p.getMobile()%>
                                    </td>
                                    <td>
                                        <a name="lnkDetail" href="/card/bind/<%=p.getId()%>" class="btn btn-success btn-sm borderNone" >修改</a>
                                        <a name="lnkDelete" pk="<%= p.getId()%>" href="javascript:;" class="btn btn-danger btn-sm borderNone" >删除</a>
                                    </td>
                                </tr>
                                <%
                                    }
                                } else {
                                %>
                                <tr>
                                    <td colspan="7">未找到数据</td>
                                </tr>
                                <% }%>
                                </tbody>
                            </table>
                            <div class="col-sm-10">
                                <div class="dataTables_paginate paging_simple_numbers" id="pLst_paginate">
                                    <page:page
                                            totalSum="<%= pager.getTotal()%>"
                                            url="<%= url%>"
                                            pageNo="<%= pager.getPage()%>"
                                            pageSize="<%= pager.getPageSize()%>"/>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </div>
    <%--<jsp:include page="foot.jsp"></jsp:include>--%>
</div>
<script src="<%= request.getAttribute("StaticHost") %>/js/jquery.dataTables.min.js"></script>
<script src="<%= request.getAttribute("StaticHost") %>/js/bootstrap-datepicker.min.js"></script>
<script src="<%= request.getAttribute("StaticHost") %>/js/bootstrap-datepicker.zh-CN.min.js"></script>
<script src="<%= request.getAttribute("StaticHost") %>/js/dataTables.bootstrap.min.js"></script>
<script src="<%= request.getAttribute("StaticHost") %>/js/adminlte.min.js"></script>

<script>

    $(function () {
        $("[name='lnkDelete']").click(function(){

            var cardBindId = $(this).attr("pk");
            if (confirm("确定删除吗？")) {
                $.ajax({
                    url: "${pageContext.request.contextPath}/card/bind/" + cardBindId,
                    type: "DELETE",
                    async: true,
                    context: this,
                    timeout: 5000,
                    success: function (data) {
                        if (null != data && data.code == 200) {
                            location.reload();
                        } else {
                            alert("失败:" + data);
                        }
                    },
                    error: function (d, s, b) {
                        alert("失败:" + b);
                    }
                });
            }
        });
    });

</script>
</body>
</html>

